package gang.com.mobelhelper.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.LinearLayout;


import com.eftimoff.androipathview.PathView;

import butterknife.BindView;
import butterknife.ButterKnife;
import gang.com.mobelhelper.MainActivity;
import gang.com.mobelhelper.R;
import gang.com.mobelhelper.common.constant.Constant;
import gang.com.mobelhelper.common.util.ACache;

/**
 * 贝赛尔曲线动画实现github地址  https://github.com/geftimov/android-pathview
 * 正常跳转传值我们都是使用这里使用ASimpleCache   它的Github地址：https://github.com/yangfuhai/ASimpleCache
 */
public class WelcomeActivity extends AppCompatActivity {


    @BindView(R.id.pathView)
    PathView mPathView;
    @BindView(R.id.activity_welcome)
    LinearLayout mActivityWelcome;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        ButterKnife.bind(this);


        mPathView.getPathAnimator()
                .delay(100)
                .duration(5000)
                .interpolator(new AccelerateDecelerateInterpolator())
                .listenerEnd(new PathView.AnimatorBuilder.ListenerEnd() {
                    @Override
                    public void onAnimationEnd() {


                        jump();

                    }


                })

                .start();
    }

    private void jump() {


        String isShowGuide = ACache.get(this).getAsString(Constant.IS_SHOW_GUIDE);

        // 第一次启动进入引导页面
        if (null == isShowGuide) {
            startActivity(new Intent(this, GuiderActivity.class));

        } else {
            startActivity(new Intent(this, MainActivity.class));
        }


        this.finish();
    }
}
